<template>
	<view class="my-page">
      <cu-navbar :is-back="false">
          <block slot="content">个人中心</block>
      </cu-navbar>
		<div class="user-center f-r a-c">
			<u-avatar :src="userInfo.avatar" size="150rpx"></u-avatar>
			<div class="userinfo">
				<div class="phone">{{ userInfo.mobile }}</div>
				<div class="id">姓名: {{ userInfo.realname }}</div>
<!--				<div class="money" @click="chongzhi">-->
<!--            充值 >-->
<!--        </div>-->
			</div>
		</div>
		<div class="order">
      <div class="title-box f-r a-c j-b">
        <div class="f-g f-r a-c">
          <div class="title-pre"></div>
          <div>抢拍订单</div>
        </div>
      </div>
      <div class="grid f-r a-c j-b">
        <div class="grid-item f-c a-c j-c" @click="toOrder2(6)">
          <u-image src="/static/icon1.png" width="54rpx" height="54rpx"></u-image>
          <div class="name">全部订单</div>
        </div>
        <div class="grid-item f-c a-c j-c" @click="toOrder2(0)">
          <u-image src="/static/icon2.png" width="54rpx" height="54rpx"></u-image>
          <div class="name">付款确认</div>
        </div>
        <div class="grid-item f-c a-c j-c" @click="toOrder2(1)">
          <u-image src="/static/icon3.png" width="54rpx" height="54rpx"></u-image>
          <div class="name">收款确认</div>
        </div>
        <div class="grid-item f-c a-c j-c" @click="toOrder2(2)">
          <u-image src="/static/icon4.png" width="54rpx" height="54rpx"></u-image>
          <div class="name">委托代卖</div>
        </div>
      </div>
			<div class="title-box f-r a-c j-b">
				<div class="f-g f-r a-c">
					<div class="title-pre"></div>
					<div>商品订单</div>
				</div>
			</div>
			<div class="grid f-r a-c j-b">
				<div class="grid-item f-c a-c j-c" @click="toOrder(6)">
					<u-image src="/static/icon6.png" width="54rpx" height="54rpx"></u-image>
					<div class="name">全部订单</div>
				</div>
				<div class="grid-item f-c a-c j-c" @click="toOrder(0)">
					<u-image src="/static/icon7.png" width="54rpx" height="54rpx"></u-image>
					<div class="name">待发货</div>
				</div>
				<div class="grid-item f-c a-c j-c" @click="toOrder(1)">
					<u-image src="/static/icon8.png" width="54rpx" height="54rpx"></u-image>
					<div class="name">待收货</div>
				</div>
			</div>
			<u-gap height="20rpx" bgColor="#f3f3f3"></u-gap>
			<div class="cell-list">
				<u-cell-group>
					<u-cell-item title="我的账户" @click="routeJump('/pages/user-info/user-info')">
					</u-cell-item>
          <u-cell-item title="我的余额" @click="routeJump('/pages/user-yue/user-yue')" url="/pages/user-yue/user-yue">
          </u-cell-item>
					<u-cell-item title="我的地址" @click="routeJump('/pages/address/address')" url="/pages/address/address">
					</u-cell-item>
					<u-cell-item title="我的推广" @click="routeJump('/pages/tuiguang/tuiguang')" url="/pages/tuiguang/tuiguang">
					</u-cell-item>
					<u-cell-item title="我的客户" @click="routeJump('/pages/kehu/kehu')" url="/pages/kehu/kehu">
					</u-cell-item>
					<u-cell-item title="联系客服" @click="routeJump('/pages/kefu/kefu')" url="/pages/kefu/kefu">
					</u-cell-item>
            <u-cell-item v-if="isAdmin" title="提现审核" @click="routeJump('/pages/tixian_shenhe/tixian_shenhe')">
            </u-cell-item>
            <u-cell-item v-if="isAdmin" title="封存/互转" @click="routeJump('/pages/fencun/fencun')">
            </u-cell-item>
            <u-cell-item title="委卖中" @click="routeJump('/pages/shangjia/shangjia')">
            </u-cell-item>
            <u-cell-item v-if="isAdmin" title="预约列表" @click="routeJump('/pages/yuyue/list')">
            </u-cell-item>
            <u-cell-item v-if="isAdmin" title="换购审核列表" @click="routeJump('/pages/order-list/chaifen_shenhe')">
            </u-cell-item>
            <u-cell-item v-if="isAdmin" title="成员订单列表" @click="routeJump('/pages/order-list/order-list2')">
            </u-cell-item>
            <u-cell-item v-if="isAdmin" title="转场管理" @click="routeJump('/pages/order-list/order-list3')">
            </u-cell-item>
				</u-cell-group>
			</div>
		</div>
		<div class="logout-btn" @click="logout">退出登录</div>
	</view>
</template>

<script>
	import UCellItem from "../../uview-ui/components/u-cell-item/u-cell-item";
  export default {
      components: {UCellItem},
      data() {
			return {
				userInfo: {
				},
          isAdmin: false
      }
		},
		onShow() {
			if (!uni.getStorageSync('token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
				return
			}
      this.$api.ismaster().then(res => {
          this.isAdmin = res.result.ismaster && res.result.ismaster.includes('掌柜')
      })
        this.$api.userInfo().then(res => {
            uni.setStorageSync("userinfo", res.result);
            this.userInfo = res.result
        })
		},
		methods: {
        routeJump(url) {
            uni.navigateTo({
                url
            })
        },
			toOrder() {
				uni.navigateTo({
					url: '/pages/product-order/product-order'
				})
			},
      toOrder2(type) {
        this.$common.navigateTo('/pages/order-list/order-list?type=' + type )
      },
			logout() {
				uni.clearStorageSync("userinfo");
				uni.clearStorageSync("username");
				uni.clearStorageSync("password");
				uni.clearStorageSync("code");
				uni.clearStorageSync("token");
				uni.clearStorageSync("address");
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			chongzhi() {
				uni.navigateTo({
					url: '/pages/chongzhi/chongzhi'
				})
			}
		}
	}
</script>

<style lang="scss">
	.my-page {
    padding-bottom: 50px;
		.logout-btn {
			margin:  20px auto;
			    width: 120px;
			    height: 34px;
				line-height: 34px;
			    border: 1px solid #ff443b;
			    border-radius: 4px;
			    font-size: 14px;
			    font-weight: 400;
			    color: #ff443b;
				text-align: center;
		}
		.cell-list {
			background-color: #fff;
		}

		.order {
			background-color: #fff;
		}

		.grid {
			background-color: #fff;
			padding: 0 50rpx 30rpx 50rpx;

			.grid-item {
				width: 150rpx;

				.name {
					margin-top: 20rpx;
				}
			}
		}

		.submit {
			height: 84upx;
			background: rgb(255, 68, 59);
			border-radius: 16upx;
			font-size: 32upx;
			font-weight: bold;
			color: #fff;
			text-align: center;
			line-height: 84upx;
			margin: 50rpx 0rpx 0;
		}

		.title-box {
			padding: 30rpx;

			.title-pre {
				display: inline-block;
				width: 3px;
				height: 16px;
				background: #ff443b;
				border-radius: 1px;
				margin-right: 10rpx;
			}

			.more {
				font-size: 28rpx;
				color: #888;
			}
		}

		.user-center {
			background: #fa433f;
			color: #fff;
			padding: 40rpx 30rpx;

			.userinfo {
				margin-left: 20rpx;
				color: #fff;

				.id {
					margin: 20rpx 0;
				}
			}
		}
	}
</style>
